<template>
  <div class="find-pwd-form app-form">
    <h3>找回密码</h3>
    <a-form :model="formState" :rules="rules">
      <a-form-item name="phone">
        <a-input placeholder="请输入手机号" v-model:value="formState.phone" />
      </a-form-item>
      <a-form-item>
        <CaptchaInput />
      </a-form-item>
      <a-form-item>
        <CaptchaBtn
          @getPhoneNum="getPhoneNum"
          v-model:phone="formState.phone"
        />
      </a-form-item>
      <a-form-item name="pwd">
        <a-input placeholder="请输入密码" v-model:value="formState.pwd" />
      </a-form-item>
      <a-form-item name="pwd">
        <a-input placeholder="请输入确认密码" v-model:value="formState.pwd" />
      </a-form-item>

      <a-row style="padding-top: 5px">
        <a-col :span="24" class="submit">
          <a-button type="primary">确认找回</a-button>
        </a-col>
        <a-col :span="24" class="msg">
          <router-link to="/login">我想起来了，去登录！</router-link>
        </a-col>
      </a-row>
    </a-form>
  </div>
</template>

<script lang="ts" setup>
import { reactive } from 'vue';

import CaptchaInput from './CaptchaInput.vue';
import CaptchaBtn from './CaptchaBtn.vue';
import { hErrorMsg } from '@/utils';

const formState = reactive({
  phone: '',
  pwd: '',
});
const rules = {
  pwd: {
    required: true,
    message: hErrorMsg('请输入密码'),
    trigger: 'blur',
  },
  phone: {
    required: true,
    message: hErrorMsg('请输入正确的手机号'),
    trigger: 'blur',
  },
};

async function getPhoneNum(fn: (avaliable: boolean) => void) {
  fn(false);
}
</script>

<style lang="scss" scoped>
.find-pwd-form {
  h3 {
    margin-top: 68px !important;
  }
  :deep(.ant-input) {
    height: 52px;
    background: #f7f7f7;
    border-radius: 6px;
  }
  :deep(.ant-form-item) {
    margin-bottom: 30px;
  }
  :deep(.ant-form-item-explain) {
    bottom: -29px;
  }
  .tip {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
  }
  .submit {
    margin-bottom: 31px;
    :deep(.ant-btn) {
      width: 100%;
      height: 48px;
      box-shadow: 0px 6px 12px 0px rgba(24, 144, 255, 0.26);
      border-radius: 6px;
    }
  }
  .msg {
    text-align: right;
    margin-bottom: 61px;
    font-size: 14px;
    line-height: 14px;
  }
}
</style>
